extends "book/base.html"
| {% load static %}

- block pagetitle
	if author
		| 作者-{{author}}
	else
		if category
			| {{category}}

- block content
	#NAVID.row(data-nav="{% if categorynav %}{{categorynav}}{% else %}navallbook{% endif %}")
		if ft_books
			for book in ft_books
				if book
					.col-xs-12.col-sm-6.col-md-4
						.panel.panel-info
							.panel-heading
								if not user.is_superuser
									a.visible-xs.btn.btn-xs.btn-primary.pull-right(href="{{book.get_absolute_url}}") 进入阅读
								h3.panel-title
									a(href="{{book.get_absolute_url}}")!= book.title
										| &nbsp;&nbsp;&nbsp;
									small
										a(href="{{book.get_category_url}}")
											| [{{book.category}}]
									span.pull-right
										small
											a(href="/?a={{book.author}}",title="{{book.author}}")
												| {{book.author|truncatechars:'7'}}
							.bookinfo.panel-body
								.frontimage
									img.pull-left(src="{%if book.front_image%}{{book.front_image.url}}{%else%}{%static 'img/nocover.jpg'%}{%endif%}")
								.caption
									- with book.get_bookrank as bookrank
										p
											| 总点击: {{bookrank.all_point}} 总推荐: {{bookrank.all_push}} 总收藏: {{bookrank.all_fav}}
										!= book.info_html|linebreaks
							if user.is_superuser
								.panel-footer.admin
									a.btn.btn-danger.btn-xs(target="_blank",href="/admin/book/book/{{book.pk}}/") 编辑信息
									a.bookfixpic.btn.btn-danger.btn-xs(href="javascript:;",data-url="{% url 'bookfixpic' book.pk %}") 更新图章
				else
					.hidden-xs.col-xs-12.col-sm-6.col-md-4
						.panel.panel-info
							.panel-heading
								h3.panel-title
									a(href="javascript:;") 暂无内容
										| &nbsp;&nbsp;&nbsp;
									small [未分类]
									span.pull-right
										small
											a(href="javascript:;",disabled="true") 暂无内容
							.bookinfo.panel-body
								.caption 暂无内容
							if user.is_superuser
								.panel-footer.hidden-xs.admin
									button.btn.btn-primary.btn-xs(disabled="true") 进入阅读
		if jt_books
			.col-xs-12.col-sm-4.col-md-3
				.row
					.col-md-12.col-xs-12.col-sm-12
						.panel.panel-primary.jt
							.panel-heading 精品推荐
							.jt.panel-body
								//- .col-md-12.col-xs-12.col-sm-12
								ul.jt.list-group
									for book in jt_books
										if book
											li.jt.list-group-item
												a(href="{{book.get_absolute_url}}",title="{{book.title}}")
													| {{book.title|truncatechars:"8"}}
												span.pull-right
													small
														a(href="/?a={{book.author}}",title="{{book.author}}")
															| {{book.author|truncatechars:'7'}}
										else
											li.jt.list-group-item 暂无内容
		if books
			if jt_books
				.col-md-9.col-xs-12.col-sm-8
					.row
						.col-md-12.col-xs-12.col-sm-12.jtl
							.panel.panel-primary.bl
								.panel-heading 书籍列表
								.panel-body.bl
									.row
										for book in books
											.col-xs-12.col-sm-6.col-md-4.jtl
												.panel.panel-info.jtl
													.panel-heading.jtl
														h4.panel-title
															a(href="{{book.get_absolute_url}}",title="{{book.title}}")
																| {{book.title}}
															small.hidden-md.hidden-sm
																| ({{book.category}})
															span.pull-right
																small
																	a(href="/?a={{book.author}}",title="{{book.author}}")
																		| {{book.author}}
										if pagination.has_other_pages
											.col-md-12.col-xs-12.col-sm-12.text-center
												.pagination.bl
													ul
														li.btn.btn-sm.bl
															a.fui-arrow-left(href="/?p=2") 更多
																span.fui-arrow-right
			else
				.col-md-12.col-xs-12.col-sm-12
					.row
						.col-md-12.col-xs-12.col-sm-12
							.panel.panel-primary
								.panel-heading 书籍列表
						for book in books
							.col-xs-12.col-sm-6.col-md-4
								.panel.panel-info
									.panel-heading
										h3.panel-title
											a(href="{{book.get_absolute_url}}",title="{{book.title}}")
												| {{book.title}}
											small
												| ({{book.category}})
											span.pull-right
												small
													a(href="/?a={{book.author}}",title="{{book.author}}")
														| {{book.author}}
									.hidden-xs.bookinfo.panel-body
										.caption
											- with book.get_bookrank as bookrank
												p
													| 总点击: {{bookrank.all_point}} 总推荐: {{bookrank.all_push}} 总收藏: {{bookrank.all_fav}}
												!= book.info_html|linebreaks
									if user.is_superuser
										.panel-footer.admin
											a.btn.btn-danger.btn-xs(target="_blank",href="/admin/book/book/{{book.pk}}/") 编辑信息
											a.bookfixpic.btn.btn-danger.btn-xs(href="javascript:;",data-url="{% url 'bookfixpic' book.pk %}") 更新图章
						if pagination.has_other_pages
							.col-md-12.col-xs-12.col-sm-12.text-center
								.pagination
									ul
										if pagination.has_previous
											li.btn.btn-sm
												a.fui-arrow-left(href="#",data-num="1")
													span.fui-arrow-left
											li.btn.btn-sm
												a.fui-arrow-left(href="#",data-num="{{pagination.previous_page_number}}")
										li.active
											a(href="javascript:;")!= pagination.number
										if pagination.has_next
											li.btn.btn-sm
												a.fui-arrow-right(href="#",data-num="{{pagination.next_page_number}}")
											li.btn.btn-sm
												a.fui-arrow-right(href="#",data-num="{{pagination.paginator.num_pages}}")
													span.fui-arrow-right
		else
			if search
				.jumbotron
					h1 真遗憾, 没找到诶!
					p 要不要去别的网站试一试?
			else
				.jumbotron
					h1 Hello, world!
					p ...

- block footerjs
	if user.is_authenticated
		script
			(function($){
				$(".bookfixpic").die().live('click', function(event){
					var this_a = $(event.target);
					$.post(this_a.data('url'),{},function(data){
						if(data.success){
							alert("正在更新本书");
						}else{
							alert(data.error_message);
						}
					},'json');
					return false;
				});
			})(jQuery);
